package com.learning.javaweb_springboot_test.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.learning.javaweb_springboot_test.entity.Student;
import com.learning.javaweb_springboot_test.entity.Teacher;
import com.learning.javaweb_springboot_test.mapper.TeacherMapper;
import com.learning.javaweb_springboot_test.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImpl implements TeacherService {

    @Autowired
    TeacherMapper teacherMapper;          //teacherMapper中虽然什么都没写，但是继承了大量的方法

    @Override
    public void addTeacher(Teacher teacher) {
        teacherMapper.insert(teacher);
    }

    @Override
    public void deleteTeacher(Integer id) {
        teacherMapper.deleteById(id);
    }

    @Override
    public void updateTeacher(Teacher teacher) {
        teacherMapper.updateById(teacher);
    }

    @Override
    public Teacher queryTeacherById(Integer id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id", id);
        return teacherMapper.selectOne(queryWrapper);
    }
}
